<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>login</title>
<script language="javascript" type="text/javascript">
function loginValidation()
{
var uName = document.loginform.uname;
var pName = document.loginform.pass;

if(validHealthNO(uName,12)){
if(validPassWrd(pName,5,12)){
	document.forms[0].submit();
}
}
return false;
}


function validHealthNO(healthNo,len)
{
var size = healthNo.value.length;
var noFormat =  /^[0-9A-Z]+$/;
if(size == 0 || size < len)
{
alert('Health Card Number must not be Empty & must be 12 chars'); 
return false;
}
if(healthNo.value.match(noFormat))  
{  
return true;  
}  
else  
{  
alert('Health Card Number is Invalid \n Use only 0-9 & A-Z characters');  
return false;  
}
}

function validPassWrd(passWrd,st,fin)
{
var passLen = passWrd.value.length;
if(passLen == 0 || passLen < st || passLen > fin )
{
alert('Password must not be Empty & must be between 5 to 12 chars'); 
return false;
}else
{
return true;
}
}
</script>
</head>
<body>
<table width=100% bordercolor="#F0F0F0" bgcolor="#CCCCCC">
<tr><th scope="col"><div align="center"><h1 align="left">Walk-in Clinics Hassle Free</h1></div></th></tr>
</table>
&nbsp;
<fieldset>
<legend><b>Login </b></legend>
<% String message = (String) request.getAttribute("message"); %>
<div style="color: red; font-weight: bold;"><%=(message != null ? message : "")%></div>
<form name="loginform" onSubmit="return loginValidation();" method="post">
<table width=50% align=center cellpadding=5 cellspacing=0 bgcolor="#D5FFD5">
<tr><td>&nbsp;</td><tr> 
<tr>
<td><div align="right">Health Card No:</div></td>
<td bgcolor="#D5FFD5"><input type="text" name="uname" value="" maxlength=12/></td>
</tr>
<tr>
<td><div align="right">Password:</div></td>
<td bgcolor="#D5FFD5"><input type="password" name="pass" value="" maxlength=12/></td>
</tr>
<tr>
<td colspan=2 align=center bgcolor="#D5FFD5"><input type="submit" name="login" value="Sign In" /></td>
</tr>
<tr>
<td colspan=2 align=right><a href="register.jsp">Register</a></td>
</tr>  
</table>
</form>
</fieldset>
</body>
</html> 